<template>
  <div>
    <div>
      <el-row type="left" justify="space-around">
        <el-col :span="6"
          ><el-input
            placeholder="请输入搜索关键词"
            prefix-icon="el-icon-search"
            size="medium"
          >
            <el-button
              type="info"
              size="medium"
              slot="append"
              icon="el-icon-search"
            ></el-button>
          </el-input>
        </el-col>
        <el-col :span="11"></el-col>
        <el-col :span="7">
          <el-button
            size="small"
            type="primary"
            @click="buffer.Bufferfrom = true"
            >添加</el-button
          ></el-col
        >
      </el-row>
      <list
        :mylist="mylist"
        :clslist="clslist"
        :pages="pages"
        @delet="spaceDELET"
        @emdel="specsEdit"
      ></list>
      <tolist
        ref="formMenu"
        :mylist="specslist"
        :buffer="buffer"
        @change="specslist"
      ></tolist>
    </div>
  </div>
</template>

<script>
import list from "../specs/components/specstable";
import tolist from "../specs/components/specsaddition";
export default {
  name: "",
  components: { list, tolist },
  data() {
    return {
      mylist: [],
      clslist: {},
      buffer: {
        Bufferfrom: false,
      },
      pages: {
        page: 1,
        size: 20,
      },
    };
  },
  created() {},
  mounted() {
    this.specslist();
  },
  methods: {
    specslist() {
      this.$api.specsList(this.pages).then((res) => {
        console.log(res);
        this.mylist = res.data.list;
      });
    },
     spaceDELET(inof) {
      let { index, row } = inof;
      this.$api.specsDel({ id: row.id }).then((res) => {
        console.log(res);
      });
      this.$confirm("此操作将永久删除该文件", "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.specslist();
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
     specsEdit(inof) {
      let { index, row } = inof;
      this.buffer.Bufferfrom = true;
      delete row.children;
      this.$refs.formMenu.attrs=row.attrs.map((item)=>{
        return {value:item}
      })
      this.$refs.formMenu.form = JSON.parse(JSON.stringify(row));
    },
  
  },
};
</script>
<style scoped lang="scss">
.el-row {
  margin-top: 20px;
}
</style>
